package com.fast.fast.common.gateway;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;

/**
 * 网关
 *
 * @author lyf
 * @date 2022/01/01 00:00 周六
 **/
@EnableCaching
@RefreshScope
@EnableFeignClients(basePackages = "com.fast.**")
@EnableDiscoveryClient
@Slf4j
@SpringBootApplication
public class FastCommonGatewayApplication {

    @SneakyThrows
    public static void main(String[] args) {
        ConfigurableApplicationContext application = SpringApplication.run(FastCommonGatewayApplication.class, args);
        Environment env = application.getEnvironment();
        String appName = env.getProperty("spring.application.name");
        String port = env.getProperty("server.port");
        String address = InetAddress.getLocalHost().getHostAddress();
        log.info("\n----------------------------------------------------------\n\t" +
                        "网关 '{}' 启动成功!\n\t" +
                        "本地地址: \t\thttp://localhost:{}\n\t" +
                        "局域网地址: \thttp://{}:{}\n\t" +
                        "----------------------------------------------------------",
                appName,
                port,
                address, port
        );
    }

}
